# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=py3-preshed
pkgver=3.0.9
pkgrel=1
pkgdesc="Cython hash tables that assume keys are pre-hashed"
url="https://github.com/explosion/preshed"
arch="all"
license="MIT"
depends="py3-cymem py3-murmurhash"
makedepends="
	cython
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	"
checkdepends="py3-pytest"
subpackages="$pkgname-doc $pkgname-pyc"
source="preshed-$pkgver.tar.gz::https://github.com/explosion/preshed/archive/v$pkgver.tar.gz"
builddir="$srcdir/preshed-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	# otherwise pytest picks up the local one,
	# which doesn't have the native shared library and fails
	cd .testenv/lib/python3.*/site-packages
	$builddir/.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}

sha512sums="
145eb9275df733984dd092e06d06ded57cbabcb229f0e3dd0357e61bd502d43dd5a70969bdb0c2239508b04bf7f37aa31afb195ab7c731e020c0a1c209fc03fd  preshed-3.0.9.tar.gz
"
